﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data;
using System.Data.SqlClient;

public class MyConnection
{
    SqlConnection con = null;

    public MyConnection()
    {
        string sqlCon = "server=HUNG-PC\\SQLEXPRESS;database=OnlineMobileRecharge;uid=sa;pwd=fat123456";
        con = new SqlConnection(sqlCon);
    }

    public SqlConnection OpenConnection()
    {
        if (con.State == ConnectionState.Closed)
            con.Open();
        return con;
    }

    public void CloseConnection(SqlConnection conn)
    {
        if (conn.State == ConnectionState.Open)
            conn.Close();
    }
}